<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<h2>로그관리</h2>

<form method="get" action="" class="searchForm" id="usersFormDiv">
<table class="table tb_search">
	<tbody>
		<tr>
			<th>메뉴</th>
			<td>
				<select name="menuUsedCd">
					<option value="">전체</option>
					<c:forEach items="${menuUsedList}" var="item">
						<option value="${item.code}"<c:if test="${pageParam.menuUsedCd == item.code}">selected="selected"</c:if> >${item.name}</option>
					</c:forEach>
				</select>
			</td>
			<th>로그타입</th>
			<td>
				<select name="logsTypeCd">
					<option value="">전체</option>
					<c:forEach items="${logTypeList}" var="item">
						<option value="${item.code}"<c:if test="${pageParam.logsTypeCd == item.code}">selected="selected"</c:if> >${item.name}</option>
					</c:forEach>
				</select>
			</td>
		</tr>
		<tr>
			<th>발생자</th>
			<td>
				<input type="text" name="userNameTxt" value="${pageParam.userNameTxt}"/>
			</td>
			<th>발생일</th>
			<td>
				<input type="text" class="dateRange" name="dateStart" value="${pageParam.dateStart}"/>
				~
				<input type="text" class="dateRange" name="dateEnd" value="${pageParam.dateEnd}"/>
			</td>
		</tr>
		<tr>
			<td colspan="4" class="textR">
				<input type="hidden" name="pageNum" value="${pageParam.pageNum}"/>
				<input type="hidden" name="orderBy" value="${pageParam.orderBy}"/>
				<span class="button medium"><button type="submit">조회</button></span>
			</td>
		</tr>
	</tbody>
</table>


<div class="clearfix searchBtn">
	<div class="floatR">
		<span class="button medium"><a href="<c:url value='/companyExcel'/>" class="excelDown">엑셀다운</a></span>
	</div>
</div>

<div class="clearfix btn5">
	<div class="floatL">
		<span class="pageDataTotal">총 <strong>${pageDataTotal}</strong> 건</span>
	</div>
	<div class="floatR">
		<select name="pageCut" class="ui-widget-content ui-corner-all" >
			<c:forEach begin="10" end="50" step="5" var="cutNum">
				<option value="${cutNum}" <c:if test="${pageParam.pageCut==cutNum}">selected="selected"</c:if>>${cutNum}</option>
			</c:forEach>
		</select>
	</div>
</div>
<c:set var="loopIndex" value="${pageParam.startNum}"/>
<c:if test="${loopIndex > 1}"><c:set var="loopIndex" value="${loopIndex-1}"/></c:if>
<table class="searchDataList tb_list">
	<thead>
		<tr>
			<th scope="row" >NO</th>
			<th scope="row" class="order" filed="menu_used_txt"><span>메뉴</span></th>
			<th scope="row" class="order" filed="logs_type_txt"><span>로그타입</span></th>
			<th scope="row" ><span>메세지</span></th>
			<th scope="row" class="order" filed="created"><span>발생일</span></th>
			<th scope="row" class="order" filed="user_id"><span>발생자ID</span></th>
			<th scope="row" class="order" filed="user_name"><span>발생자</span></th>
			<th scope="row" class="order" filed="user_ip"><span>IP</span></th>
		</tr>
	</thead>
	<tbody binText="기록된 로그가 없습니다.">
		<c:choose>
			<c:when test="${!empty pagingList}">
				<c:forEach items="${pagingList}" var="item" varStatus="loop">
		            <tr>
		                <td class="textC"><span>${loopIndex+loop.count}</span></td>
		                <td>${item.menu_used_txt}</td>
		                <td>${item.logs_type_txt}</td>
		                <td>${item.msg}</td>
		                <td class="textC"><fmt:formatDate value="${item.created}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
		                <td>${item.user_id}</td>
		                <td>${item.user_name}</td>
		                <td>${item.user_ip}</td>
		            </tr>
		        </c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
					<td scope="col" colspan="9" class="bin">기록된 로그가 없습니다.</td>
				</tr>
			</c:otherwise>
		</c:choose>
	</tbody>
</table>

<c:import url="../layout/paginate.jsp"></c:import>
</form>
<script type="text/javascript" src="<c:url value='/res/js/content/pageList.js'/>"></script>
<script type="text/javascript" >

$(function(){
    $( "[name=dateStart]" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "[name=dateEnd]" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "[name=dateEnd]" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "[name=dateStart]" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
});
</script>
